package com.ybxx.system.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import com.ybxx.core.dao.impl.BaseDaoImpl;
import com.ybxx.system.dao.PermissionDao;
import com.ybxx.system.model.Permission;

public class PermissionDaoImpl extends BaseDaoImpl<Permission> implements
		PermissionDao {
	private JdbcTemplate jdbcTemplate;
	public PermissionDaoImpl(){
		super(Permission.class);
	}
	public List<Permission> queryUserPermission(String sql){
		return jdbcTemplate.query(sql, new RowMapper<Permission>(){

			public Permission mapRow(ResultSet rs, int index)
					throws SQLException {
				Permission permission=new Permission();
				permission.setPid(rs.getString("pid"));
				permission.setPname(rs.getString("pname"));
				permission.setFid(rs.getString("fid"));
				permission.setChecked(rs.getBoolean("checked"));
				return permission;
			}});
	}
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
}
